package com.myteam.fugaocrm.sqldb.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Select;

import com.myteam.fugaocrm.modle.FgProjectPafrolRecord;

public interface FgProjectPafrolRecordMapper {
	
	@Select("select * from fg_project_pafrol_record where is_delete = 0 and project_id = #{projectId}")
    List<FgProjectPafrolRecord> selectAll(Integer projectId);
    
    void insertOne(FgProjectPafrolRecord entity);
    
    void updateOne(FgProjectPafrolRecord entity);
    
    /** 定时提醒查询（巡检） */
    @Select(
    	"SELECT " + 
    		"record.*," + 
    		"project.project_name " + 
    	"FROM fg_project_pafrol_record record " + 
    	"LEFT JOIN fg_project project ON project.project_id = record.project_id " +
    	"WHERE record.is_delete = 0 AND record.is_complete = 'N' AND patrol_date IS NOT NULL AND to_days(patrol_date) < to_days(now())"
    )
    List<FgProjectPafrolRecord> selectAllNotComplete();
    
}
